package com.docker.manege.container;

import com.docker.core.mvc.dao.BaseDao;
import com.jfinal.kit.Okv;
import com.jfinal.plugin.activerecord.Record;

import java.util.List;

/**
 * @Author ldl
 * @Create 2021/01/12 012 10:49
 */
public class ContainerDao extends BaseDao {

    @Override
    protected String getSqlTplNameSpace() {
        return "docker.container";
    }

    public boolean save(Record container) {
        return save("docker_container_info", "cr_id", container);
    }

    public boolean exist(String serverId, String containerName, String containerId) {
        return tplQueryInt("exist", serverId, containerName, containerId) > 0;
    }

    public Record info(String containerId) {
        return info("docker_container_info", "cr_id", containerId);
    }

    public boolean update(Record container) {
        return update("docker_container_info", "cr_id", container);
    }

    public Record info(Okv cond) {
        return tplSPInfo("info.cond", cond);
    }

    public Record cmd(Okv cond) {
        return tplSPInfo("cmd", cond);
    }

    public List<Record> look(Okv cond) {
        return tplSPList("look", cond);
    }

    public Record detail(Okv cond) {
        return tplSPInfo("detail", cond);
    }

}
